package org.peipito.prs;

import org.peipito.prs.engine.GameEngine;

import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.view.SurfaceView;

public class CountDown {

	private static final String TAG = CountDown.class.getSimpleName();
	
	private Bitmap [] countDowns;
	private int countDown;
	private GameEngine gameEngine;
	
	public CountDown(Bitmap [] countDowns){
		this.countDowns = countDowns;
		this.countDown = 5;
	}
	
	private long previousGameTime;
	
	public void update(long gameTime){
		if(countDown>0){
			if(gameTime - previousGameTime > 1000){
				countDown --;
				previousGameTime = gameTime;
			}
		} else { //	show result;
			GameEngine.gamePhase = GameEngine.RESULT;
		}
	}
	
	public void draw(Canvas canvas,SurfaceView surfaceView) {
		if(GameEngine.gamePhase == GameEngine.COUNTDOWN){
			canvas.drawBitmap(countDowns[countDown],0,300,null);
		}
	}
	
	public void handleActionDown(int x, int y,SurfaceView surfaceView) {
		
	}
	
	public void setEngine(GameEngine gameEngine){
		this.gameEngine = gameEngine;
	}
	
	public void init(){
		countDown = 5;
	}
	
}
